#include "dbglobal.h"

#include <QDateTime>
#include <QThread>
#include <QCoreApplication>

dbglobal::dbglobal(QObject *parent) :
    QObject(parent)
{
}

///
/// \brief dbglobal::MyMSleep
/// 延时函数 最大延时时间 1s
///
/// \param msecs
/// 延时的时间 单位ms 最大1000
///
/// \return
///
void dbglobal::MyMSleep(int msecs)
{
    QDateTime dieTime = QDateTime::currentDateTime().addMSecs(msecs);

    int i = 0;
    while (QDateTime::currentDateTime() < dieTime)
    {
        QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
        QThread::usleep(1000);
        if (i > 100)
        {
            break;
        }
        i ++;
    }

    return ;
}
